﻿using System;
using Hazza.UserInput.Models;
using Orchard;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;


namespace Hazza.UserInput.Drivers
{
    public class HazzaInputPartDriver : ContentPartDriver<HazzaInputPart> {
        private readonly IOrchardServices services;

        public HazzaInputPartDriver(IOrchardServices services) {
            this.services = services;
        }

        protected override string Prefix
        {
            get { return "HazzaInputPart"; }
        }

        protected override DriverResult Display(HazzaInputPart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape("Parts_HazzaInputPart",
                () => shapeHelper.Parts_HazzaInputPart(
                    Model: part));
        }

        protected override DriverResult Editor(HazzaInputPart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_HazzaInputPart_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: "Parts/HazzaInputPart",
                    Model: part,
                    Prefix: Prefix));
        }

        protected override DriverResult Editor(HazzaInputPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
}